package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.MainContentBean;
import com.project.mapper.IMainContentMapper;
import com.project.service.IMainContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

/**
 * @author lyl
 * description:
 */
@Service
@Transactional
public class MainContentServiceImpl implements IMainContentService {
    @Autowired
    private IMainContentMapper iMainContentMapper;

    @Override
    public PageInfo<MainContentBean> showMCByPage(int pageNo, int themeId, String mcTitle, String username, LocalDate startDate, LocalDate endDate) {
        PageHelper.startPage(pageNo, 3);
        PageInfo<MainContentBean> info = PageInfo.of(iMainContentMapper.showMCByPage(themeId, mcTitle, username, startDate, endDate));
        return info;
    }

    @Override
    public void addMC(MainContentBean mainContentBean, int fkUserId, int fkThemeId) {
        iMainContentMapper.addMC(mainContentBean, fkUserId, fkThemeId);
    }

    @Override
    public MainContentBean findMCById(int mainContentId) {
        return iMainContentMapper.findMCById(mainContentId);
    }
}
